<?php
include_once('libs/class.database.php');
class Cetakdetilstruk
{
	public $link;
	function __construct()
	{
		$konek= new Database();
		$this->link=$konek->connect();
	}
	function getPembelian($id_username)
	{
		$query=$this->link->query("SELECT * FROM pembelian WHERE id_pembeli='$id_username' ORDER BY tgl_beli DESC");
		$jml_data=$query->rowCount();
		if($jml_data>=1)
		{
			$hasil=$query->fetchAll();
			return $hasil;
		}
		else
		{
			return $jml_data;
		}
	}
		function getMasterDetail($id_beli)
	{
		$query=$this->link->query("SELECT c.id_master, c.id_beli,c.id_penjual, c.id_produk, c.harga harga, c.jumlah jumlah, c.nama nama, d.nama nama_produk  FROM (SELECT a.id_master, a.id_beli,a.id_penjual, a.id_produk, a.harga, a.jumlah, b.nama FROM master_pembelian a LEFT JOIN biodata b ON a.id_penjual=b.id_username) c  LEFT JOIN produk d ON c.id_produk=d.id WHERE c.id_beli='$id_beli'");
		$jml_data=$query->rowCount();
		if($jml_data>=1)
		{
			$hasil=$query->fetchAll();
			return $hasil;
		}
		else
		{
			return $jml_data;
		}
	}
	}
?>